﻿<%@ Page Title="" Language="C#" MasterPageFile="~/GUI/User/User.Master" AutoEventWireup="true" CodeBehind="TrangChu.aspx.cs" Inherits="ProjectWebNhac.GUI.User.TrangChu" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script src="js/FancyBox/source/jquery.fancybox.js" type="text/javascript"></script>
    <link href="js/FancyBox/source/jquery.fancybox.css" rel="stylesheet" type="text/css" />
    <script src="js/FancyBox/source/jquery.fancybox.pack.js" type="text/javascript"></script>
    <script src="js/FancyBox/lib/jquery.mousewheel-3.0.6.pack.js" type="text/javascript"></script>
    <script src="js/main.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            var tempSong = '';

            $('.nologin').showPopup({
                top: 50,
                closeButton: ".close_popup",
                scroll: false,
                onClose: function () {
                }
            });
            $(".add").fancybox({
                'scrolling': 'no',
                'titleShow': false,
                width: 440,
                height: 340,
                'onClosed': function () {
                    $("#login_error").hide();
                }
            });
            $('.add').on("click", function () {
                tempSong = $(this).text();
            });
            var dropPlaylist = $('#<%=dropPlaylist.ClientID %>');
            $("#btnAdd").on("click", function () {
                if (dropPlaylist.val() == "-1") {
                    alert("Vui lòng chọn playlist");
                } else {
                    AddtoPlaylist();
                }
            });
            $("#btnCreate").on("click", function () {

                if ($('#txtPlaylist').val() == "" || $('#txtPlaylist').val() == null) {
                    alert("Vui lòng đặt tên playlist");
                } else {
                    CreateNewPL();
                }

            });
            function AddtoPlaylist() {
                var data = "{ 'MaPL': '" + dropPlaylist.val() + "','MaBaiHat':'" +
                 tempSong + "'}";
                $.ajax({
                    type: "POST",
                    url: "BaiHat.aspx/AddPlayList",
                    data: data,
                    contentType: "application/json",
                    dataType: "json",
                    success: function (msg) {
                        if (msg.d) {
                            alert("Thêm bài hát thành công");
                            $.fancybox.close();
                        } else {
                            alert("Bài hát này đã tồn tại");
                        }


                        // Replace the div's content with the page method's return.

                    }
                });
            }
            var taikhoan = $('#<%=txtUserName.ClientID%>');
            function CreateNewPL() {
                var data = "{ 'tenPlaylist': '" + $('#txtPlaylist').val() + "','taikhoan':'" +
                 taikhoan.val() + "'}";
                $.ajax({
                    type: "POST",
                    url: "BaiHat.aspx/CreateNewPL",
                    data: data,
                    contentType: "application/json",
                    dataType: "json",
                    success: function (msg) {
                        if (msg.d != "failed") {
                            alert("Thêm playlist thành công");
                            dropPlaylist.append("<option value='" + msg.d +
                            "'>" + $('#txtPlaylist').val() + "</option>");
                            $('#txtPlaylist').val("");
                            $.fancybox.close();
                        } else {
                            alert("Tên playlist này đã tồn tại");
                        }

                    }
                });
            }
        });
    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
        <section id='main'>
          <div class='container'>
                <div class='row'>
                    <div class='span9 content'>
                        <div class='new-items span6 no-margin'>
                            <h1>Bài hát nổi bật</h1>
                            <hr />
                            <div class="wrapper-search">
                                <asp:Repeater ID="reBaiHat" runat="server" 
                                    onitemdatabound="reBaiHat_ItemDataBound">
                                <ItemTemplate>
                                    <div class='track-line'>
                                <div class='span6 no-margin'>
                                    <div class="jp-audio custom" id="jp_container_1">
                                        <div class="jp-type-single">
                                            <div class="jp-gui jp-interface">
                                                
                                                <div class='name'>
                                                    <div class="jp-title">
                                                        <ul>
                                                            <li><a href="ChiTietBaiHat.aspx?MaBH=<%#Eval("MaBaiHat") %>"><%#Eval("TenBaiHat") %></a> </li>
                                                            <li>Trình bày : 
                                                                <asp:Repeater ID="reDSCaSiBaiHat" runat="server">
                                                                <ItemTemplate>
                                                                    <a href="ChiTietCaSi.aspx?MaCS=<%#Eval("MaCaSi") %>"><%#Eval("TenCaSi")%>,</a>  
                                                                </ItemTemplate>
                                                                </asp:Repeater>
                                                                
                                                            | <a href="#"><%#Eval("TenTheLoai") %></a></li>
                                                            <li>Đăng bởi : <a href="#"><%#Eval("TaiKhoan") %></a> | Ngày đăng:<%#Eval("NgayThem", "{0:dd-MM-yyyy}")%>| Lượt nghe: <%#Eval("LuotNghe") %></li>
                                                        </ul>
                                                    </div>
                                                    
                                                </div>
                                                <div class="right" style="width: 50px;">
                                            <%if (Session["ThanhVien"] != null)
                                              {
                                                %>
                                                 <a href='#playlistAdd' class='add'><%#Eval("MaBaiHat") %></a>
                                                <%  
                                              }
                                              else
                                              { %>
                                           <a  href="#popup_login" class='nologin'><%#Eval("MaBaiHat") %></a>
                                           <%} %>

                                            <asp:ImageButton ID="imDown" CommandArgument='<%#Eval("LinkBaiHat") %>' CommandName="download" runat="server" ImageUrl="img/down.png" style="margin-top: 7px;width: 16px;"></asp:ImageButton>
                                        
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                
                            </div>
                                </ItemTemplate>
                                </asp:Repeater>
                            

                          
                                </div>
                                
                            <a href="#" title='All Mp3' class='btn btn-main'>Nghe Hết<a>
                        </div>
                         <h1>Album hay nhất</h1>
                                
                     <asp:Repeater ID="reHotAlbum" runat="server">
                        <ItemTemplate>
                         <div class='weekly-features span3'>
                           
                            <hr />
                            <figure>
                              <img width="150px" height="150px" src="../../HinhAnh/Album/<%#Eval("HinhAnh") %>" />
                            </figure>
                            <h2><a href="ChiTietAlbum.aspx?MaAB=<%#Eval("MaAlbum") %>"><%#Eval("TenAlbum") %></a></h2>
                            <h3><a href="ChiTietCaSi.aspx?MaCaSi=<%#Eval("MaCaSi") %>"><%#Eval("TenCaSi") %></a></h3>
                            <span>Lượt nghe : <%#Eval("LuotNghe") %></span><br />
                           
                        </div>
                      
                        </ItemTemplate>
                        </asp:Repeater>

               
                         <div class='span9 news no-margin homepage'>
                            <h1>Album mới nhất</h1>
                            <hr />
                             <asp:Repeater ID="reAlbumMoiNhat" runat="server">
                             <ItemTemplate>
                             <article class='span3'>
                                <div class='inner'>
                                    <figure>
                                        <img src="../../HinhAnh/Album/<%#Eval("HinhAnh") %>" alt="">
                                    </figure>
                                    <h2><a href='ChiTietAlbum.aspx?MaAlbum=<%#Eval("MaAlbum") %>'><%#Eval("TenAlbum") %></a></h2>
                                    <p>
                                       <%#Eval("MoTa") %> ...
                                    </p>
                                </div>
                                <div class='bottom'>
                                    <a class='comments'><%#Eval("LuotBinhLuan") %></a>

                                    <div class='star-rating'>
                                        <a href='#' title='1 star' class='full'>1 star</a>
                                        <a href='#' title='2 stars' class='full'>2 stars</a>
                                        <a href='#' title='3 stars' class='full'>3 stars</a>
                                        <a href='#' title='4 stars' class='full'>4 stars</a>
                                        <a href='#' title='5 stars' class='empty'>5 stars</a>
                                    </div>
                                </div>
                            </article>
                             </ItemTemplate>
                             </asp:Repeater>
                            
                           
                        </div>
                         <div class='span9 news no-margin homepage'>
                            <h1>Video mới nhất</h1>
                            <hr />
                        <div class="mostcontainer">
                	<ul>
                        <asp:Repeater ID="reVideo" runat="server" 
                            onitemdatabound="reVideo_ItemDataBound">
                        <ItemTemplate>
                            <li>
                              
                        	<div class="vediodiv" style="padding-top: 0px;">
                            	<a href="ChitietVideo.aspx?MaVideo=<%#Eval("MaVideo") %>"><img src="../../HinhAnh/Video/<%#Eval("AvatarClip") %>" alt="" style=" height: 102px;    width: 200px;" />

                                	<span class="time"><%#Eval("Timespan") %></span>
                                </a>
                            </div>
                        	<div class="clear"></div>
                        	<p class="ttle" style="margin-bottom: 0px;"><a class="colr2"  href="ChitietVideo.aspx?MaVideo=<%#Eval("MaVideo") %>"><%#Eval("TenVideo") %></a></p>
                            <p class="ttle" style="margin-bottom: 0px;">
                            <asp:Repeater ID="reDanhSachCaSiVideo" runat="server">
                            <ItemTemplate>
                            <a class="colr2"  href="ChiTietCaSi.aspx.aspx?MaCaSi=<%#Eval("MaCaSi")%>"><%#Eval("TenCaSi")%>.</a>
                            </ItemTemplate>
                            </asp:Repeater>
                            
                            </p>
							<p class="viewcounts"><%#Eval("LuotXem") %> lượt xem</p>
							<p>Đăng Bởi: <a href="#" class="undrlne"><%#Eval("TaiKhoan") %></a></p>
                        </li>
                        </ItemTemplate>
                        </asp:Repeater>
                    	
                    </ul>
                </div>
                        </div>
                        
                        <div class="standard-pagination">
                            <ul>
                                <%--<li class="active"><a href="#" class="btn">1</a></li>
                                <li><a href="#" class="btn">2</a></li>--%>
                                
                                <asp:Literal ID="liPage" runat="server"></asp:Literal>
                            </ul>
                        </div>
                         
                         <asp:TextBox style="display:none" ID="txtUserName" runat="server" Text=""></asp:TextBox>
                        <div style="display:none;width:300px;height:200px" id="playlistAdd" >
	
	    	        <p id="login_error">Thêm bài hát vào playlist</p>
		                     <p>
			<label for="login_name" style="width:100px;float:left">Chọn playlist: </label>
            <asp:DropDownList ID="dropPlaylist" style="margin-top: -3px;width: 190px;" runat="server">
            </asp:DropDownList>
		</p>
		                     <p>
			<input type="button" class="registration btn btn-blue" value="Thêm" id="btnAdd" />
		</p>
	                         <p>
            <label for="login_name" style="width:80px;float:left">Tên Playlist </label>
            <input type="text" id="txtPlaylist"/>
        </p>
                             <p>
			<input type="button" class="registration btn btn-blue" value="Tạo mới playlist" id="btnCreate" />
		</p>
                    </div>
                   

                    </div>




                    <aside class='span3'>
                        <div class='inner'>
                            <div class='cart'>
                                <div class='top-line'>
                                    <h1>BXH bài hát hay nhất</h1>
                                </div>
                                <asp:Repeater ID="reBXHNhac" runat="server">
                                <ItemTemplate>
                                <div class='list-line'>
                                    <a href="ChiTietBaiHat.aspx?MaBaiHat='<%#Eval("MaBaiHat") %>'"><%#Eval("TenBaiHat") %></a> 
                                    <span>
                                    <%#Eval("LuotNghe")%>
                                    </span>
                                </div>
                                </ItemTemplate>
                                </asp:Repeater>
                                

                                <div class='list-line'>
                                      <input type="button" id="btnLogin" class="sign-in btn btn-main" name="open_popup" rel="login" href="#popup_login" value="Nghe Hết"/> 
                                </div>


                                
                            </div>

                             <div class='cart'>
                                <div class='top-line'>
                                    <h1>BXH video hay nhất</h1>
                                </div>

                                <asp:Repeater ID="reBXHVideo" runat="server" 
                                     onitemdatabound="reBXHVideo_ItemDataBound">
                                <ItemTemplate>
                                  <div class='top-line'>
                                  <div class='span4'>
                                  <a href="ChitietVideo.aspx?MaVideo=<%#Eval("MaVideo") %>">
                                    <img width="200px"   src="../../HinhAnh/Video/<%#Eval("AvatarClip") %>" style="padding-top: 5px;"/>
                                  </a> </div>
                                   <div class='span8'>
                                   <ul>
                                   	<li><a href="ChitietVideo.aspx?MaVideo=<%#Eval("MaVideo") %>"> <%#Eval("TenVideo")%> </a></li>
                                    <li> 
                                    <asp:Repeater ID="reCaSiBXHVideo" runat="server">
                                    <ItemTemplate>
                                    <a href="ChiTietCaSi.aspx?MaCaSi=<%#Eval("MaCaSi") %>"> <%#Eval("TenCaSi") %>, </a>
                                    </ItemTemplate>
                                    </asp:Repeater>
                                    </li>
                                   </ul>
                                   
                                  
                                   </div>
                                </div>
                                </ItemTemplate>
                                </asp:Repeater>
                              
                                 
                                
                            </div>
                          <%--  <a href='#' title='Download application' class='app-link'>
                                <div class='app-ad'>
                                    <h3>Download our app for iphone <br /><strong>for free</strong></h3>
                                </div>
                            </a>--%>
                        </div>
                     
                    </aside>

                </div>

           </div>

        </section>
   
</asp:Content>
